home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Documentation / Books / Learn Java on the Macintosh / Learn Java Projects / 08.01 - truth tester / TruthTester.java < prev    next >
Text File  |  1996-04-22  |  1KB  |  41 lines

  1. /* -------------------------------------------------------------
  2. This applet illustrates if-else statements.
  3.  
  4. Java's classes: Applet    (applet)
  5.                 System    (lang)     
  6.  
  7. Custom classes: TruthTester
  8.  
  9. ------------------------------------------------------------- */
  10.  
  11. public class TruthTester extends java.applet.Applet {
  12.    public void init() {
  13.    
  14.       boolean    hasCar, hasTimeToGiveRide;
  15.       boolean    nothingElseOn, newEpisode, itsARerun;
  16.     
  17.       hasCar = true;
  18.       hasTimeToGiveRide = true;
  19.     
  20.       if (hasCar && hasTimeToGiveRide)
  21.          System.out.println("Hop in - I'll give you a ride!");
  22.       else
  23.          System.out.println("I've either got no car, no time, or both!");
  24.     
  25.       nothingElseOn = true;
  26.       newEpisode = true;
  27.     
  28.       if (newEpisode || nothingElseOn)
  29.           System.out.println("Let's watch Star Trek!");
  30.       else
  31.           System.out.println("Something else is on or I've seen this one.");
  32.         
  33.       nothingElseOn = true;
  34.       itsARerun = true;
  35.     
  36.       if (nothingElseOn || (!itsARerun))
  37.           System.out.println("Let's watch Star Trek!");
  38.       else
  39.           System.out.println("Something else is on or I've seen this one.");
  40.    }
  41. }